<template>
  <div class="mweb-my-container">
    <div class="user-info-section">
      <div class="avatar-container">
        <img :src="userAvatar" alt="用户头像" class="user-avatar">
      </div>
      <div class="user-details">
        <div class="user-name">{{ userName }}</div>
        <div class="user-role">{{ userRole }}</div>
      </div>
    </div>
    
    <div class="menu-section">
      <div 
        v-for="(item, index) in menuItems" 
        :key="index" 
        class="menu-item"
        @click="handleMenuClick(item)"
      >
        <div class="menu-icon">
          <i :class="item.icon"></i>
        </div>
        <div class="menu-title">{{ item.title }}</div>
        <div class="menu-arrow">
          <i class="fas fa-chevron-right"></i>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
// 移动端个人中心组件
import { ref, onMounted } from 'vue'

// 用户信息
const userAvatar = ref('')
const userName = ref('用户名')
const userRole = ref('普通用户')

// 菜单项
const menuItems = ref([
  { title: '个人信息', icon: 'fas fa-user', route: '/user-info' },
  { title: '我的订单', icon: 'fas fa-list-alt', route: '/my-orders' },
  { title: '账户设置', icon: 'fas fa-cog', route: '/settings' },
  { title: '帮助中心', icon: 'fas fa-question-circle', route: '/help' },
  { title: '关于我们', icon: 'fas fa-info-circle', route: '/about' }
])

// 处理菜单点击
const handleMenuClick = (item) => {
  console.log('点击菜单项:', item.title)
  // 这里可以添加路由跳转或其他操作
}

// 组件挂载时获取用户信息
onMounted(() => {
  // 这里可以添加获取用户信息的逻辑
  // 例如从API获取或从本地存储读取
  userAvatar.value = 'https://resource.teld.cn/teldimage/defaultAvatar.png' // 默认头像
})
</script>

<style scoped lang="scss">
.mweb-my-container {
  width: 100%;
  height: 100%;
  background-color: #f5f5f5;
  display: flex;
  flex-direction: column;
}

.user-info-section {
  background-color: #fff;
  padding: 20px 16px;
  display: flex;
  align-items: center;
  margin-bottom: 10px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.avatar-container {
  margin-right: 16px;
}

.user-avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  object-fit: cover;
}

.user-details {
  flex: 1;
}

.user-name {
  font-size: 18px;
  font-weight: 500;
  color: #333;
  margin-bottom: 4px;
}

.user-role {
  font-size: 14px;
  color: #666;
}

.menu-section {
  background-color: #fff;
  flex: 1;
}

.menu-item {
  display: flex;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid #f0f0f0;
  position: relative;
}

.menu-icon {
  width: 24px;
  text-align: center;
  margin-right: 12px;
  color: #666;
}

.menu-title {
  flex: 1;
  font-size: 16px;
  color: #333;
}

.menu-arrow {
  color: #ccc;
  font-size: 14px;
}
</style>